import 'package:common/utils/log_util.dart';
import 'package:flutter/services.dart';

import '../../constant/channel_name_constant.dart';
import '../../network/code_msg_model.dart';

///用于传递字符串和半结构化的信息（双向有返回值）
class BaseMessageChannel extends BasicMessageChannel{
  static final BaseMessageChannel  _instance = BaseMessageChannel._internal(ChannelNameConstant.basicMessageChannelName,const JSONMessageCodec());

  factory BaseMessageChannel() => _instance;

  BaseMessageChannel._internal(super.name, super.codec);

  void initMessageChannel(){
    _instance.setMessageHandler((dynamic message) async {
      LogUtil.stdPrint('message = $message');
      return baseResponseModelToJson(CodeMsgModel.success());
    });
  }
}